package com.tm.util;

/**
 * 淘宝开放平台短信发送工具类
 */
import com.taobao.api.ApiException;
import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import com.taobao.api.request.AlibabaAliqinFcSmsNumSendRequest;
import com.taobao.api.response.AlibabaAliqinFcSmsNumSendResponse;

public class TaobaoSmsUtilEx {
	
	static final String appkey = "24649353";
    static final String secret = "eb6562a7f8e0821e855801ae146caba5";
    static final String url = "http://gw.api.taobao.com/router/rest";
	
    /**
     * 发送短信
     * @param mobile 手机号
     * @param mobilecode 验证码
     * @param sms_template_code 短信模板代码
     * @return
     * @throws ApiException
     */
	public static AlibabaAliqinFcSmsNumSendResponse sendSms(String mobile, String mobilecode, String sms_template_code) throws ApiException{
		TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
		AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest();
//		req.setExtend("123456");
		req.setSmsType("normal");
		req.setSmsFreeSignName("悟空外赚");
		req.setSmsParamString("{\"code\":\"" + mobilecode + "\",\"product\":\"alidayu\"}");
		req.setRecNum(mobile);
		req.setSmsTemplateCode(sms_template_code);
		AlibabaAliqinFcSmsNumSendResponse rsp = client.execute(req);
		
		return rsp;
	}

}
